import RescacheMgr from "../framework/inc/rescachemgr";
import ViewBase from "./viewbase";
import StagerMgr from "./../framework/inc/stagemgr";
import PhyWorld from "./fight/phyworld";
import { TweenMax } from "gsap";

export default class ViewEnd extends ViewBase {
    constructor(sfile) {
        super("viewend");
        this._res_mgr = RescacheMgr.getInstance();

        this.initGraph();
        this.runAction();
    }

    initGraph() {
        //ui_sp
        let uibtn_sp = d.sp("#ui_end", "ui_btn_end");
        // let uibtn = new THREE.SpriteMaterial({map:this._res_mgr.getTexture("ui_end")});
        // let uibtn_sp = new THREE.Sprite(uibtn);
        uibtn_sp.position.y = -5;
        this.add(uibtn_sp);

        this._btnend = uibtn_sp;
    }

    runAction() {
        TweenMax.to
            (
                this._btnend.scale,
                1,
                {
                    x: 1.5,
                    y: 1.5,
                    z: 1.5,
                    repeat: -1,
                    yoyo: true
                },

            )
    }

    onTouchCell(cell) {
        if (cell.name == "uibtn_end") {
            StagerMgr.getInstance().clearView();
            PhyWorld.getWorld().reLoad();
        }
    }
}